package cn.edu.lingnan.fruitshop.controller;

import cn.edu.lingnan.fruitshop.service.GoodstableService;
import cn.edu.lingnan.fruitshop.service.GoodstypeService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.service.AddressService;
import cn.edu.lingnan.fruitshop.service.OrdertableService;
import cn.edu.lingnan.fruitshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.service.GoodstableService;
import cn.edu.lingnan.fruitshop.service.GoodstypeService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.service.AddressService;
import cn.edu.lingnan.fruitshop.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import cn.edu.lingnan.fruitshop.service.GoodstableService;
import cn.edu.lingnan.fruitshop.service.GoodstypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpSession;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.annotation.Resource;
import javax.servlet.http.HttpSession;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseBody;

@Controller
public class PageController {
    @Autowired
    private GoodstypeService goodstypeService;
    @Autowired
    private GoodstableService goodstableService;
    @Autowired
    private AddressService addressService;
    @Resource
    private OrdertableService ordertableService;



    //主页面
    @GetMapping("/index")
    public String toIndex(Model model) {
        return goodstableService.showGoods( model);
    }

    // 跳转至注册页面
    @GetMapping("/toRegister")
    public String toRegister(){
        return "user/register";
    }

    //  跳转至登录页面
    @GetMapping("/toLogin")
    public String toLogin(){
        return "user/login";
    }

    // test
//    @GetMapping("/toIndex")
//    public String toIndex(){
//        return "user/index";
//    }


    // 跳转至首页
    @GetMapping("/toIndex")
    public String toIndex(){
        return "user/index";
    }

    // 跳转至重设密码页面
    @GetMapping("/toResetPwd")
    public String toResetPwd(){
        return "/user/resetPwd";
    }

    /**
     * 跳转到商家个人信息界面
     * @param model
     * @param session
     * @return
     */
    @RequestMapping("/toSellerCenterInfo")
    public String toSellerCenterInfo(Model model, HttpSession session){
        return addressService.toSellerCenterInfo(model, session);
    }

    /**
     * 跳转用户个人信息界面
     * @param model
     * @param session
     * @return
     */
    @RequestMapping("/toUserCenterInfo")
    public String toUserCenterInfo(Model model, HttpSession session){
        return addressService.toUserCenterInfo(model, session);
    }

    /**
     * 跳转用户订单界面
     * @param model
     * @param session
     * @return
     */
    @RequestMapping("/toUserCenterOrder")
    public String toUserCenterOrder(Model model, HttpSession session,Integer currentPage, Integer pageSize){
        return ordertableService.toUserCenterOrder( model,session,currentPage,  pageSize);
    }
    /**
     * 跳转用户地址界面
     * @param model
     * @param session
     * @return
     */
    @RequestMapping("/toUserCenterSite")
    public String toUserCenterSite(Model model, HttpSession session){
        return addressService.toUserCenterSite(model, session);
    }

    // 跳转到添加商品界面
    @GetMapping("/toAddGoods")
    public String toAddGoods(Model model){
        return goodstypeService.toAddGoods(model);
    }

    // 跳转到商品信息界面
    @GetMapping("/toGoodsInfo")
    public String toGoodsInfo(Model model,HttpSession session,Integer pageNum){
        return goodstableService.toGoodsInfo(model,session,pageNum);
    }

    //    跳转地址信息管理界面
    @RequestMapping("/toUserCenterAdmin")
    public String toUserCenterAdmin(Model model,HttpSession session){
        return addressService.toUserCenterAdmin(model, session);
    }





}
